package com.price.common.util

import com.price.common.extend.doCustomCrashListener
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

fun Long.formatTime(pattern: String?="yyyy-MM-dd HH:mm:ss"):String{
    val simpleFormatter=SimpleDateFormat(pattern, Locale.ENGLISH)
    return simpleFormatter.format(Date(this))
}
fun String.formatDate(pattern: String?="yyyy-MM-dd HH:mm:ss"): Date? {
    runCatching {
        val simpleFormatter=SimpleDateFormat(pattern, Locale.ENGLISH)
        return simpleFormatter.parse(this)
    }.onFailure {
        doCustomCrashListener?.onCrash(it)
    }
    return null
}